import socket
import time
import sys

#===============================================================================
# Server definitions
#===============================================================================

SBS_SERVER_MAX_CONNECTIONS = 200
SBS_SERVER_ALLOWED_SYNC_DELAY = 1 # seconds
SBS_SERVER_SEQ_NO_START = 1

#===============================================================================
# Client definitions
#===============================================================================

SBS_CLIENT_ALLOWED_SYNC_DELAY = 5 # seconds
SBS_CLIENT_SEQ_NO_START = 0

#===============================================================================
# Shared definitions
#===============================================================================

SBS_INVALID_ID = -1
SBS_MAX_SEQ_NO = 65535
SBS_RECV_BUFFER_SIZE = 1024

# What would you call these?
SBS_TCPSERVER_DELIMITER = '/' # separates messages
SBS_NETWORK_MESSAGE_DELIMITER = '|' # separates parameters inside messages

#===============================================================================
# SBSNetwork exceptions that might be raised
#===============================================================================

class SBSNetworkFailure(Exception):
    ''' Raised when sending data on a socket fails '''
    
    def __init__(self, message = None):
        Exception.__init__(self, message)
        
class SBSNetworkTimeout(Exception):
    ''' Raised when you expect a reply, but never get one '''
    
    def __init__(self, message = None):
        Exception.__init__(self, message)
